import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem } from '@/utils/storage'

Vue.use(Vuex)

const hmttToken = 'HMTT-TOKEN'
export default new Vuex.Store({
  state: {
    user: getItem(hmttToken) // 存储token
  },
  mutations: { // payload 承载的数据
    setUser (state, payload) {
      state.user = payload
      setItem(hmttToken, state.user)
    },
    getToken (state) {
      state.user = getItem(hmttToken)
    }
  },
  actions: {},
  modules: {}
})
